package com.qf.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Aspect
@Component
public class AopConfig {
    @Pointcut("execution(* com.qf.service.impl.AccountServiceImpl.transfor(..))")
    public void pc(){

    }
//    @Before("pc()")
//    public void before(){
//        System.out.println("在方法之前执行了");
//    }
//    @After("pc()")
//    public void after(){
//        System.out.println("最终执行");
//    }
//    @AfterReturning("pc()")
//    public void afterReturning(){
//        System.out.println("在方法之后执行");
//    }
//    @AfterThrowing("pc()")
//    public void afterThrowing(){
//        System.out.println("在异常时执行");
//    }
    @Around("pc()")
    public Object around(ProceedingJoinPoint joinPoint){
        try {
            System.out.println("前置");
            Object result = joinPoint.proceed();
            System.out.println("后置");
            return result;
        } catch (Throwable e) {
            e.printStackTrace();
            System.out.println("异常");
        } finally {
            System.out.println("最终");
        }
        return null;
    }
}
